<template>
  <div class="home">
      <div class="content">
        <router-view></router-view>
        <div class="pos" >
          <van-icon name="envelop-o" />
        </div>
      </div>
      <foo></foo>
  </div>
</template>

<script>
// @ is an alias to /src
import foo from "@/components/footer.vue"
import { Icon } from 'vant';
export default {
  name: 'Home',
   components:{
    foo,
    [Icon.name]: Icon,
  },
  methods:{
    move(e){
            console.log(e)
            let odiv = e.target;        //获取目标元素
            
            //算出鼠标相对元素的位置
            let disX = e.clientX - odiv.offsetLeft;
            let disY = e.clientY - odiv.offsetTop;
            document.onmousemove = (e)=>{       //鼠标按下并移动的事件
                //用鼠标的位置减去鼠标相对元素的位置，得到元素的位置
                let left = e.clientX - disX;    
                let top = e.clientY - disY;
                
                //绑定元素位置到positionX和positionY上面
                this.positionX = top;
                this.positionY = left;
                
                //移动当前元素
                odiv.style.left = left + 'px';
                odiv.style.top = top + 'px';
            };
            document.onmouseup = (e) => {
                document.onmousemove = null;
                document.onmouseup = null;
            };
        }    
  }
}
</script>
<style lang="scss" scoped>
*{
    margin: 0;
    padding: 0;
    list-style: none;
    box-sizing: border-box;
}
.content{
  width: 100%;
  background: #F0F2F5;
  position: relative;
}
.pos{
        position: fixed;     /*定位*/
        bottom:80px;
        right: 10px;
        width:60px;
        height: 60px;
        border-radius:50px;
        background:#007AFF;       /*设置一下背景*/
        text-align:center;
        line-height:80px;
        .van-icon{
          color:white;
          font-size:30px;
        }
    }
</style>